package test5;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-04-05
 * Time: 14:08
 */
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int year = scanner.nextInt();
        int month = scanner.nextInt();
        int day = scanner.nextInt();
        int[] months = {0, 31, 28, 31, 30,
                31, 30, 31, 31,
                30, 31, 30, 31};
        boolean flag = false;
        if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
            flag = true;
        }
        if (flag) {
            months[2] = 29;
        }
        int sum = 0;
        for (int i = 1; i < month; i++) {
            sum += months[i];
        }
        sum += day;
        System.out.println(sum);
    }
}
